import java.util.Arrays;
import java.util.Comparator;

public class TestComparable {

	public static void main(String[] args) {

		Student[] students = new Student[4];

		students[0] = new Student();
		students[0].setFirstName("Svetlin");
		students[0].setLastName("Nakov");
		students[0].setAge(29);

		students[1] = new Student();
		students[1].setFirstName("Valentin");
		students[1].setLastName("Ivanov");
		students[1].setAge(25);

		students[2] = new Student();
		students[2].setFirstName("Mario");
		students[2].setLastName("Peshev");
		students[2].setAge(20);

		students[3] = new Student();
		students[3].setFirstName("Vasil");
		students[3].setLastName("Stoqnov");
		students[3].setAge(21);

		for (Student s : students) {
			System.out.println(s);
		}
		
		// Sort students with Comparable
		Arrays.sort(students);
		System.out.println();
		System.out.println("Sorted students by age");
		for (Student s : students) {
			System.out.println(s);
		}
		
		// Sort students with Comparator
		Comparator<Student> comparator = new LastNameComparator();
		Arrays.sort(students, comparator);
		System.out.println();
		System.out.println("Sorted students by last name");
		for (Student s : students) {
			System.out.println(s);
		}
	}

}
